/**
 * @description: 用户
 */
import { defHttp } from '../http'
import type { CommonAPI } from '../schema/all'

/** 获取图片验证码 */
export const getApiCaptchaImageApi: CommonAPI<'/api/captcha/image', 'get'> = (
  params
) =>
  defHttp.get(
    `/api/captcha/image`,
    { params },
    {
      isTransformResponse: false
    }
  )

/** 验证图片验证码 */
export const postApiCaptchaVerifyApi: CommonAPI<
  '/api/captcha/verify',
  'post'
> = (data) =>
  defHttp.post(
    `/api/captcha/verify`,
    { data },
    {
      isTransformResponse: false
    }
  )

/** 登录 */
export const postApiLoginApi: CommonAPI<'/api/login', 'post'> = (data) =>
  defHttp.post(
    `/api/login`,
    { data },
    {
      isTransformResponse: false
    }
  )

/** 获取用户信息 */
export const getApiUserDetailApi: CommonAPI<'/api/user', 'get'> = (params) =>
  defHttp.get(`/api/user`, { params })

/** 更新用户信息 */
export const updateApiUserApi: CommonAPI<'/api/user', 'post'> = (data) =>
  defHttp.post(`/api/user`, { data })

/** 修改用户密码 */
export const updateApiUserPasswordApi: CommonAPI<
  '/api/user/password',
  'post'
> = (data) => defHttp.post(`/api/user/password`, { data })

/** 检查是否需要验证码 */
export const getCaptchaPreCheckApi: CommonAPI<
  '/api/captcha/pre-check',
  'get'
> = (params) => defHttp.get(`/api/captcha/pre-check`, { params })
